/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;

/**
 *
 * @author Administrator
 */
public abstract class BaseFrame extends JFrame{
    protected Box main, quests,bs;
    protected JButton forward,back;
    
    public BaseFrame(String s) {
        super(s);
        Eventer evt = new Eventer();
        main = Box.createVerticalBox();
        quests = Box.createVerticalBox();
        bs = Box.createHorizontalBox();
        forward = new JButton("Forward, ahoy! >>>");
        forward.addActionListener(evt);
        back = new JButton("<<< Not sure about that last one.");
        back.addActionListener(evt);
        bs.add(Box.createHorizontalStrut(2));
        bs.add(back);
        bs.add(Box.createHorizontalGlue());
        bs.add(forward);
        bs.add(Box.createHorizontalStrut(2));
        main.add(quests);
        main.add(Box.createVerticalGlue());
        main.add(bs);
        deactivateBack();
        this.add(main);
        this.setSize(400,400);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
    }
    
    public abstract void loadNext();
    public abstract void loadPrevious();
    
    protected void deactivateBack() { back.setEnabled(false); }
    protected void activateBack() { back.setEnabled(true); }
    protected void deactivateForward() { forward.setEnabled(false); }
    protected void activateForward() { forward.setEnabled(false); }
    
    private class Eventer implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {
            JButton b = (JButton) e.getSource();
            if(b==back) loadPrevious();
            else if(b==forward) loadNext();
        }
        
    }
    
}
